package com.mz.mattress.client.util;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class RandomBirthdayGenerator {

    public static List<String> generateRandomBirthdays(int count) {
        List<String> birthdays = new ArrayList<>();
        Random random = new Random();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

        for (int i = 0; i < count; i++) {
            // 随机年份(1960-2000)
            int year = 1960 + random.nextInt(41);
            // 随机月份(1-12)
            int month = 1 + random.nextInt(12);
            // 随机日期(1-28/29/30/31)
            int day = 1 + random.nextInt(LocalDate.of(year, month, 1).lengthOfMonth());

            LocalDate date = LocalDate.of(year, month, day);
            birthdays.add(date.format(formatter));
        }

        return birthdays;
    }

    public static void main(String[] args) {
        List<String> randomBirthdays = generateRandomBirthdays(10);
        System.out.println("随机生成的10个出生日期：");
        randomBirthdays.forEach(System.out::println);
    }
}